package org.zpmis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.zpmis.config.MinioConfig;
import org.zpmis.util.MinioUtil;

/**
 * 服务启动后创建默认桶
 */
@Component
public class FileServiceProviderApplicationRunner implements ApplicationRunner {

    @Autowired
    private MinioUtil minioUtil;
    @Autowired
    private MinioConfig minioConfig;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //创建配置文件业务桶
        if (minioConfig.getBusinessBucket()!=null){
            for (String vaule: minioConfig.getBusinessBucket().values()) {
                minioUtil.createBucket(vaule);
            }
        }
        //创建默认桶
        minioUtil.createBucket(MinioUtil.DEFAUT_BUCKET);
    }
}
